﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/* Copyright (c) 2010 CBaxter
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
 * IN THE SOFTWARE. 
 */

namespace Xpedite.Test
{
  [TestClass]
  public class VerifyTest
  {
    [TestMethod]
    public void TestNotNull()
    {
      Verify.NotNull(new Object(), "obj");
      Expect.Exception(() => Verify.NotNull((Object)null, "obj"), new ArgumentNullException("obj", "Value cannot be null."));
    }

    [TestMethod]
    public void TestNotNullOrEmpty()
    {
      var ex = new ArgumentException("Value cannot be a null or empty.", "obj");

      Verify.NotNullOrEmpty(new List<Object> { new Object() }, "obj");
      Expect.Exception(() => Verify.NotNullOrEmpty((List<Object>)null, "obj"), ex);
      Expect.Exception(() => Verify.NotNullOrEmpty(new List<Object>(), "obj"), ex);
    }

    [TestMethod]
    public void TestNotWhiteSpace()
    {
      var ex = new ArgumentException("Value cannot be a null, empty or whitespace only.", "obj");

      Verify.NotWhiteSpace("a", "obj");
      Expect.Exception(() => Verify.NotWhiteSpace(" ", "obj"), ex);
      Expect.Exception(() => Verify.NotWhiteSpace(null, "obj"), ex);
      Expect.Exception(() => Verify.NotWhiteSpace(String.Empty, "obj"), ex);
      Expect.Exception(() => Verify.NotWhiteSpace(Environment.NewLine, "obj"), ex);
    }

    [TestMethod]
    public void TestTrue()
    {
      var ex = new ArgumentException("My customized message.", "obj");

      Verify.True(true, "obj", "My customized message.");
      Expect.Exception(() => Verify.True(false, "obj", "My customized message."), ex);
    }

    [TestMethod]
    public void TestFalse()
    {
      var ex = new ArgumentException("My customized message.", "obj");

      Verify.False(false, "obj", "My customized message.");
      Expect.Exception(() => Verify.False(true, "obj", "My customized message."), ex);
    }
  }
}
